/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.quartz;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;

/**
 *
 * @author Mansur
 */
@Singleton
public class PtaskSchedulerManager {
    
    Scheduler scheduler;
    
    @Inject
    public PtaskSchedulerManager(Scheduler scheduler) {
        this.scheduler = scheduler;
    }
    
    public void start() throws SchedulerException{
        JobDetail pTaskJob = new JobDetail("personalBatch", "personalEmail_group", CronPTaskEmailJob.class);
//        Trigger daily = TriggerUtils.makeHourlyTrigger("personalTask_trigger",12,00);
        Trigger daily = TriggerUtils.makeDailyTrigger("personalTask_trigger",01,00);
//        Trigger daily = TriggerUtils.makeMinutelyTrigger("personalTask_trigger");
        scheduler.scheduleJob(pTaskJob, daily);
        scheduler.start();
    }
    
    public void shutdown() throws SchedulerException{
        scheduler.shutdown();
    }
    
}
